package QC.MessageBox.beans.wxmsg.normalmsg;

/**
 * Created by Andaren on 2017/6/5.
 * Used for: 根据OpenID列表群发【订阅号不可用，服务号认证后可用】
 */

import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;

import java.util.List;

public class WXGroupSendByList {

    private List<String> openIdList;

    private String mediaId;

    private String msgType;

    private Integer sendIgnoreReprint;

    public List<String> getOpenIdList() {
        return openIdList;
    }

    public WXGroupSendByList setOpenIdList(List<String> openIdList) {
        this.openIdList = openIdList;
        return this;
    }

    public String getMediaId() {
        return mediaId;
    }

    public WXGroupSendByList setMediaId(String mediaId) {
        this.mediaId = mediaId;
        return this;
    }

    public String getMsgType() {
        return msgType;
    }

    public WXGroupSendByList setMsgType(String msgType) {
        this.msgType = msgType;
        return this;
    }

    public Integer getSendIgnoreReprint() {
        return sendIgnoreReprint;
    }

    public WXGroupSendByList setSendIgnoreReprint(Integer sendIgnoreReprint) {
        this.sendIgnoreReprint = sendIgnoreReprint;
        return this;
    }

    public JsonObject toJson() {
        JsonArray toUsers = new JsonArray(openIdList);
        JsonObject groupSendJson = new JsonObject()
                .put("touser", toUsers);
        switch (msgType) {
            case "mpnews" :
                JsonObject mpNews = new JsonObject()
                        .put("media_id", mediaId);
                groupSendJson
                        .put("mpnews", mpNews)
                        .put("msgtype", "mpnews");
                break;
            case "mpvideo" :
                JsonObject mpVideo = new JsonObject()
                        .put("media_id", mediaId)
                        .put("title", "TITLE")
                        .put("description", "DESCRIPTION");
                groupSendJson
                        .put("mpvideo", mpVideo)
                        .put("msgtype", "mpvideo");
                break;
        }
        groupSendJson.put("send_ignore_reprint", sendIgnoreReprint);
        return groupSendJson;
    }
}
